#include <stdarg.h>

#include "Record.h"
#include "Common.h"
#include "WLogInterface.h"

namespace WLog
{
	Record::Record(int nLevel, int nLine, const string & strFuncName, const string & strFileName)
	{
		this->m_nLevel = nLevel;
		this->m_nLine = nLine;
		this->m_strTime = getTimeStr(now_time_t());
		this->m_strFuncName = strFuncName;
		this->m_strFileName = strFileName;
	}

	Record::~Record()
	{

	}

	void Record::operator () (const char* format, ...)
	{		
        if (getLog()->getOutLevel() <= this->m_nLevel)
        { 
		    va_list arglist;
		    va_start(arglist, format );
		    this->m_strMsg = vstringFormat(format, arglist);
		    getLog()->pushRecord(*this);
		    va_end( arglist );
        }
	}
}
